NCD

Section: User Commands (1)
Updated: 20 May 1995
Index Return to Main Contents

 

NAME

ncd - Ninux Change Directory: browse & select directories

 

SYNOPSIS

ncd [ -options ] [ directory ]

 

DESCRIPTION

ncd is an interactive fullscreen directory browser that lets you select and change to the desired directory. It also lets you change quickly in non-interactive mode to a directory selected in the command line. ncd supports incomplete directory specification in the command line, and is able to perform automatic search in browser mode.

If you provide a directory name in the command line, ncd will run in non-interactive mode, and will try to change to the next directory that matches completely or partially the specified one.

If you don't provide a directory name in the command line, ncd will run in interactive mode. You can browse up and down the directory tree, search for a directory, and accept or cancel the selection of a directory to change to.

To get a faster response, ncd keeps a directory tree database in the user's home directory (obtained from $HOME environment variable). The database actually consists on a couple of files: .ncd_htree, that keeps the directory tree starting from the user home directory, and .ncd_ftree that keeps the full system directory tree, starting from the root directory /. All the home tree stored somewhere in the full tree file .ncd_ftree is discarded, and it is recreated based on the home tree read from .ncd_htree. In this way, the user can add/delete directories below his home directory and rebuild just the home .ncd_htree. database, avoiding to rebuild the long .ncd_free full system tree.

The program can run in two scope modes: home-scope mode or full-scope mode. In home-scope mode, only the home directory tree is available, and the program has no view of any directory external to this local tree. In full-scope mode, the full system tree starting from / is available for view and search operations. Normally the mode is automatically selected based on the current work directory at invocation time: home-scope mode is selected if the current directory is located under the home directory. Otherwise, full-scope is selected. This behaviour can be overriden using command line options. If you specify a directory in the command line (non-interactive mode) you can easily force full-scope mode starting the directory name with a slash /. This does not mean that the directory must hang from the root directory; to do this, add two slashes, except for root directory selection, that just needs one slash.

If the current work directory at invocation time is not registered in the program database files, the database (home or full depending on scope mode) is automatically rebuilt. This can be overriden using command line options.

 

COMMAND LINE OPTIONS

You can supply command line options to customize some ncd actions. Options can be grouped behind a single -. You can also specify default options in the NCD_OPTS environment variable, using the same sintax as in the command line. Command line options override NCD_OPTS options.

This is a list of the supported command line options:

-f
select full-scope mode (starting from /). On rebuild, both .ncd_ftree and .ncd_htree are rebuilt.
-h
select home-scope mode (starting from $HOME). On rebuild, only .ncd_htree is rebuilt.
-H
select automatic-scope mode. This will choose full-scope or home-scope depending on the current working directory at invocation time. This is the default scope mode.
-r
force rebuilding the database (home or full, depending on the scope mode).
-R
disable the database forced rebuild. This cancels any previous -r, but does not cancel an automatic rebuild (use -A to cancel that one).
-a
select automatic rebuild mode. if the current working directory at invocation time is not in the program database, a rebuild is performed (home or full, depending on the scope mode). This is the default auto-rebuild mode.
-A
disable automatic rebuild mode.
-v
Verbose on. Usefull for debug purposes or if you get bored while rebuilding the full tree.
-V
Verbose off. This is the default verbose mode.
-d
dumps directory tree. This will make a nice listing of the directory tree to stdout (home or full, depending on the scope). Just usefull to export the directory tree to a text file. The program will exit inmediately after the listing, returning an error code (not 0), it will not perform any change directory operation.
-D
Cancels any previous -d.
-t
Force text-chars display of the directory tree. If not forced, curses line-art characters are used. Curses chars are nice on terminals that suport line-art characters (as the linux console), but you get an ugly view on other terminal types. If you use -t, you get a bit better display.
-T
cancels any previous -t and also cancels automatic line-art/text-char select ( -x ). So this forces curses chars display.
-x
selects automatically line-art/text-chars display of the directory tree. This is the default.
-l
View expanded links ( ldir -> dir/ )
-L
View compacted links ( ldir@ ). This is the default.
-? -i
Shows a summary of command line options.

 

BROWSER KEYS

When invoqued in interactive mode, these are the character sequences and keys to use the browser.

KeyDown or Ctrl+N:
Move down (next brother).
KeyUp or Ctrl+P:
Move up (previous brother).
KeyLeft or Ctrl+B:
Move left (father).
KeyRight or Ctrl+F:
Move right (son).
KeyHome or Ctrl+A:
Move to first directory in tree ( $HOME or / ).
KeyEnd or Ctrl+E:
Move to last descendant of current node.
KeyPgUp or Ctrl+U:
Move one page up.
KeyPgDn or Ctrl+V:
Move one page down.
KeyF7 or Ctrl+O:
Last directory of previous line.
KeyF8 or Ctrl+J:
First directory of next line.
Ctrl+T:
Opposite movement of KeyRight. This is not KeyLeft. Keyleft moves back to the father directory.
KeyText (any text key or displayable character):
Adds the character to the search string. As you add chars, the program will try to match the resulting string to a directory in the tree. If no match is possible, the character is rejected. The match is partial, so it is not necessary to type a whole directory name to match it. If you want to force a total match, add a final slash / to the search string. After you add a slash you can go on adding chars, so actually the search is not limited to a simple directory name, but can also search for paths.
KeyF9 or Ctrl+K:
Move to next directory that matches the current search field.
Backspace or Ctrl+H:
Delete last character from the search field.
Del or Ctrl+D:
Clears completely the search field.
KeyF5 or Ctrl+L:
If the current selection is a link, follow it to the destination directory.
KeyF6 or Ctrl+G:
Toggles between viewing expanded links ( ldir -> dir/ ) and compacted links ( ldir@ ). The initial mode is command line selected using -l and -L. The default mode is to show compacted links.
KeyF4 or Ctrl+W:
Repaint the full screen. Use this when some background process disturbs your display, or some other user tries to write(1) or talk(1) to you.
KeyF2 or Ctrl+R:
Performs a directory tree rescan. The directory database is rebuilt (home or full, depending on the scope mode).
KeyF3 or Ctrl+Y:
Toggle the scope mode, between home and full scope.
Return or Enter or Ctrl+M:
Accepts the directory selected, and exits changing the current working directory to it.
KeyF10 or Esc or Ctrl+X or Meta+X:
Quit. Cancels directory selection.
KeyF1 or Ctrl+I:
Displays a little help screen.

 

SHELL ALIAS/FUNCTION

ncd is actually an executable binary and a shell alias or function that calls it; in this way, we can change the working directory of the current shell. The return value of the binary executable is 0 if the user has selected a valid directory. On error or if the operation has been cancelled, the program returns a value different to 0. The destination directory is returned in the file $HOME/ncd_sdir allows blind changing to the directory kept in $HOME/ncd_sdir without testing the return value of the program.

Assuming that the binary program is /usr/bin/ncd, the shell alias/function should be the following,

for the bash shell, define this function:


      function ncd()  
      { 
         /usr/bin/ncd $*; 
         if [ $? = 0 ]; then  
            cd "$(cat $HOME/.ncd_sdir)"; 
         fi
      }
  for the tcsh shell, define this alias (here shown in two lines; actually it's just one line):


   alias ncd '/usr/bin/ncd * ;
              if $? == 0 cd "`cat $HOME/.ncd_sdir`" '

You can include this alias/function in your login script, or in the system wide login script. See bash(1) or tcsh(1) manpages for help on this.

 

ENVIRONMENT

NCD_OPTS
You can specify default options in this environment variable, using the same sintax as in the command line. Command line options override NCD_OPTS values.

 

FILES

$HOME/.ncd_htree home tree database.

$HOME/.ncd_ftree full tree database.

$HOME/.ncd_sdir directory selected in last execution.

 

AUTHOR


  Borja Etxebarria <borja@bips.bi.ehu.es
                   <jtbecgob@s835cc.bi.ehu.es>

 

BUGS

Sure a lot.

Please, report any bug or improvement to the author Include a complete, self-contained example that will allow the bug to be reproduced, and say which version of ncd you are using.

 

COPYRIGHT

Copyright © 1995, Borja Etxebarria
                    Basque Country University

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   

SEE ALSO

bash(1), tcsh(1)


 

Index

NAME
SYNOPSIS
DESCRIPTION
COMMAND LINE OPTIONS
BROWSER KEYS
SHELL ALIAS/FUNCTION
ENVIRONMENT
FILES
AUTHOR
BUGS
COPYRIGHT
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 15:51:14 GMT, November 05, 2024